Enterprise applications that model workflow-type business processes are dependent on notifications that certain temporal events have occurred in order to manage the semantic state transitions that are intrinsic to the business processes that they model. To fit this need, timer service for a programmable class can be added to and managed by a container to provide a reliable and transactional notification service for timed events. Here a programmable class (also referred to as class) can be but is not limited to, a Java bean, an Enterprise Java Bean (EJB), an interface, a module, and other suitable concepts, and EJB will be used to illustrate the various embodiments of the invention in the following context. One scenario of when the timer service may be used is to send out a notification when an EJB instance remains in a certain state for an elapsed amount of time. For example, an EJB instance representing an expense report that needs to be approved by a manager should be registered with a timer when it is created so that when the timer expires, the certain business logic handling timeout in the EJB instance is called back upon to email the manager and the employee that the expense report is still waiting for approval. If the expense report is approved before the reminder timer expires, the timer could be cancelled.
A timeout failure occurs when the business logic handling timeout event fails. Under such circumstance, the failed timeout logic should be retried for a number of times before an exception is thrown in order to minimize the impact of the timeout failure. However, the mechanism to support such retry feature is not currently provided by many timer service systems.
In addition, since a timer is typically created by an EJB instance within the scope of a transaction and can be associated with other EJB instances, such as instances of stateless session beans or message driven beans, it is possible that the timer may be accessed by multiple transactions under a multi-threaded environment. Many current timer service systems cannot adequately control the concurrent access to the timer, which often causes the mal-operation or failure of certain threads involved.